﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Way.Bus.Controllers;
using Way.EAP.DataAccess.Entity;
using Way.Contract.Data.ControllerData;
using Way.EAP.DataAccess.Data;
using Way.Contract.Data;
using Way.Contract;
using Way.EAP.DataAccess.Regulation;
using Way.Bus.WMS.Model;
using Way.Bus.WMS.ST.Model;
using Way.Bus.WMS.ST.Controllers.Company;
using Way.Contract.MVC;

namespace Way.Bus.WMS.ST.Controllers.Company
{
    public class WLCompanyController : CompanyController
    {

        //显示在菜单
        protected override string OnControllerName()
        {
            return "物流公司管理";
        }
        //菜单中url路径
        protected override string OnGetPath()
        {
            return "Views/CRM/WLCompanys.htm";
        }
        //说明
        protected override string OnGetControllerDescription()
        {
            return "物流公司管理";
        }
        
        public static void InitWLCompany(ModelData data, ItemData item)
        {
            data.title = "物流公司";
            if (item.IsField("FTYPE"))
                item.visible = false;
            if (item.IsField("FHOMEPAGE"))
                item.visible = true;
        }
        protected override void OnInitViewChildItem(Way.Contract.Data.ModelData data, Way.Contract.Data.ItemData item)
        {
            base.OnInitViewChildItem(data, item);
            if (data.name.EndsWith("ST_Customer"))
            {
                //修改弹出窗口的title
                data.title = "物流公司";
                if (item.IsField("FTYPE"))
                    item.visible = false;
                if (item.IsField("FHOMEPAGE"))
                    item.visible = true;
            }
            if (data.name.EndsWith("ST_CustomerAdress"))
                data.visible = false;
            if (data.name.EndsWith("ST_Materials"))
                data.visible = false;
        }
        protected override void OnAdding(Way.Contract.MVC.ControllerBase.SaveEvent item)
        {
            base.OnAdding(item);
            ST_Customer cm = item.Item as ST_Customer;
            cm.FTYPE = "1";
        }
          protected override void OnGetWhereing(IModel m, List<Way.EAP.DataAccess.Regulation.SQLWhere> where,loadItem item)
        {
            base.OnGetWhereing(m, where, item);
            SQLWhere sw = new SQLWhere();
            sw.ColumnName = "FTYPE";
            sw.Value = "1";
            where.Add(sw);
        }
    

    }
}

